﻿using Financial.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Financial.Data
{
    public class ExpenseDL
    {
        FLUXEntities context = new FLUXEntities();

        public List<Expense> GetExpenses()
        {
            return context.Expenses.ToList();
        }

        public List<Expense> GetExpenses(int? parentId)
        {
            return context.Expenses.Where(e => e.ParentId == parentId).ToList();
        }

        public void CreateSaveToDatabase(Expense expense)
        {
            context.Expenses.Add(expense);
            context.SaveChanges();
        }
    }
}
